﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="AssemblyRegistration" nillable="true" type="AssemblyRegistration" />
  <xs:complexType name="AssemblyRegistration">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="XrmServerDetails" type="XrmServerDetails" />
      <xs:element minOccurs="0" maxOccurs="1" name="Registrations" type="ArrayOfRegistration" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="XrmServerDetails">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="ServerAddress" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="OrganizationName" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="XrmCredentials" type="XrmCredentials" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="XrmCredentials">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="Domain" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="UserName" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="Password" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ArrayOfRegistration">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Registration" nillable="true" type="Registration" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="Registration">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="AssemblyPath" type="xs:string" />
      <xs:element minOccurs="1" maxOccurs="1" name="AssemblySourceType" type="XrmAssemblySourceType" />
      <xs:element minOccurs="1" maxOccurs="1" name="IsolationMode" type="XrmIsolationMode" />
      <xs:element minOccurs="0" maxOccurs="1" name="Plugins" type="ArrayOfPlugin" />
      <xs:element minOccurs="0" maxOccurs="1" name="SolutionUniqueName" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="XrmAssemblySourceType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Database" />
      <xs:enumeration value="Disk" />
      <xs:enumeration value="GAC" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="XrmIsolationMode">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Invalid" />
      <xs:enumeration value="None" />
      <xs:enumeration value="Sandbox" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="ArrayOfPlugin">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Plugin" nillable="true" type="Plugin" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="Plugin">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="PluginName" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="Steps" type="ArrayOfPluginStep" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ArrayOfPluginStep">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="PluginStep" nillable="true" type="PluginStep" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="PluginStep">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="UnsecureConfiguration" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="SecureConfiguration" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="Name" type="xs:string" />
      <xs:element minOccurs="1" maxOccurs="1" name="Mode" type="XrmPluginStepMode" />
      <xs:element minOccurs="1" maxOccurs="1" name="Rank" nillable="true" type="xs:int" />
      <xs:element minOccurs="1" maxOccurs="1" name="InvocationSource" type="XrmPluginStepInvocationSource" />
      <xs:element minOccurs="0" maxOccurs="1" name="PluginMessage" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="PrimaryEntity" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="SecondaryEntity" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="ImpersonatingUserDomainName" type="xs:string" />
      <xs:element minOccurs="1" maxOccurs="1" name="Stage" type="XrmPluginStepStage" />
      <xs:element minOccurs="1" maxOccurs="1" name="Deployment" type="XrmPluginStepDeployment" />
      <xs:element minOccurs="0" maxOccurs="1" name="Description" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="Images" type="ArrayOfImage" />
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="XrmPluginStepMode">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Asynchronous" />
      <xs:enumeration value="Synchronous" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="XrmPluginStepInvocationSource">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Parent" />
      <xs:enumeration value="Child" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="XrmPluginStepStage">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Invalid" />
      <xs:enumeration value="PreValidation" />
      <xs:enumeration value="PreOperation" />
      <xs:enumeration value="PostOperation" />
      <xs:enumeration value="PostOperationDeprecated" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="XrmPluginStepDeployment">
    <xs:restriction base="xs:string">
      <xs:enumeration value="ServerOnly" />
      <xs:enumeration value="OfflineOnly" />
      <xs:enumeration value="Both" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="ArrayOfImage">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Image" nillable="true" type="Image" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="Image">
    <xs:sequence>
      <xs:element minOccurs="1" maxOccurs="1" name="ImageType" type="XrmImageType" />
      <xs:element minOccurs="0" maxOccurs="1" name="EntityAlias" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="Attributes" type="ArrayOfString" />
      <xs:element minOccurs="0" maxOccurs="1" name="MessageProperty" type="xs:string" />
      <xs:element minOccurs="1" maxOccurs="1" name="Merge" nillable="true" type="ImageMerge" />
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="XrmImageType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="PreImage" />
      <xs:enumeration value="PostImage" />
      <xs:enumeration value="Both" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="ArrayOfString">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="ImageMerge">
    <xs:restriction base="xs:string">
      <xs:enumeration value="None" />
      <xs:enumeration value="Parent" />
      <xs:enumeration value="Child" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>